package com.tedu.healthcounse.controller;

import com.tedu.common.response.JsonResult;
import com.tedu.healthcounse.pojo.dto.HealthCounseParam;
import com.tedu.healthcounse.pojo.dto.HealthCounseQuery;
import com.tedu.healthcounse.pojo.entity.HealthCounse;
import com.tedu.healthcounse.pojo.vo.HealthCounseVO;
import com.tedu.healthcounse.service.HealthCounseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/healthcounse")
public class HealthCounseController {
  @Autowired
    private HealthCounseService healthCounseService;

     @GetMapping("select")
     public JsonResult select(HealthCounseQuery healthCounseQuery) {
      log.debug("查询文字列表,参数:{}", healthCounseQuery);
        List<HealthCounseVO> List = healthCounseService.select(healthCounseQuery);
        return JsonResult.ok(List);
    }

    @PostMapping("delete/{id}")
    public JsonResult delete(@PathVariable Integer id) {
        log.debug("删除文章:参数={}", id);
        healthCounseService.delete(id);
        return JsonResult.ok();
    }

    @PostMapping("save")
    public JsonResult save( HealthCounseParam healthCounseParam) {
        log.debug("保存文章:参数={}", healthCounseParam);
         healthCounseService.save(healthCounseParam);
        return JsonResult.ok();
    }

}
